package com.todo.sight.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.sight.application.frontend.service.SightInfoAggService;
import com.todo.sight.application.frontend.service.SightReportAggService;
import com.todo.sight.application.iface.frontend.SightFrontendIface;
import com.todo.sight.application.iface.frontend.request.QuerySightByCityAndNameParam;
import com.todo.sight.application.iface.frontend.request.QuerySightDetailByPoiParam;
import com.todo.sight.application.iface.frontend.request.QuerySightSummaryListByPoiIdParam;
import com.todo.sight.application.iface.frontend.request.ReportSightPoiByUserParam;
import com.todo.sight.application.iface.frontend.response.SightDetailVO;
import com.todo.sight.application.iface.frontend.response.SightInfoVO;
import com.todo.sight.application.iface.frontend.response.SightSummaryVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/5/14 13:42
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/sight")
@Tag(name = "景点信息前台接口", description = "景点信息前台接口")
public class SightFrontendController implements SightFrontendIface {

    @Resource
    private SightReportAggService sightReportAggService;
    @Resource
    private SightInfoAggService sightInfoAggService;

    @Override
    @Operation(summary = "用户上报景点POI信息")
    @PostMapping("/reportSightPOIByUser")
    public BizResponse<Boolean> reportSightPOIByUser(@RequestBody ReportSightPoiByUserParam param) {
        if (param == null) {
            return BizResponse.paramError("操作失败，请重新尝试");
        }
        if (!param.baseCheck()) {
            return BizResponse.paramError("上报信息验证失败，数据缺失，请检查后重新操作");
        }
        return sightReportAggService.reportSightPOIByUser(param);
    }

    @Override
    @Deprecated
    @Operation(summary = "根据城市和名称查询POI信息-模糊匹配-迁移至搜索逻辑")
    @PostMapping("/querySightByCityAndName")
    public BizPageResponse<SightInfoVO> querySightByCityAndName(@RequestBody QuerySightByCityAndNameParam param) {
        if (param == null) {
            return BizPageResponse.paramError("操作失败，请重新尝试");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.paramError("查询失败，请刷新后重试");
        }
        return sightInfoAggService.querySightByCityAndName(param);
    }

    @Override
    @Operation(summary = "根据poiId查询景点详情")
    @PostMapping("/querySightDetailByPoi")
    public BizResponse<SightDetailVO> querySightDetailByPoi(@RequestBody QuerySightDetailByPoiParam param) {
        if (param == null) {
            return BizResponse.paramError("操作失败，请重新尝试");
        }
        if (!param.baseCheck()) {
            return BizResponse.paramError("查询失败，请刷新后重试");
        }
        return sightInfoAggService.querySightDetailByPoi(param);
    }

    @Override
    @Operation(summary = "根据PoiId列表查询景点概要信息列表")
    @PostMapping("/querySightSummaryListByPoiId")
    public BizResponse<List<SightSummaryVO>> querySightSummaryListByPoiId(@RequestBody QuerySightSummaryListByPoiIdParam param) {
        if (param == null) {
            return BizResponse.paramError("操作失败，请重新尝试");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询完成，请选择合适数据做查询");
        }
        return sightInfoAggService.querySightSummaryListByPoiId(param);
    }
}
